/*
 * UnaryTree.java
 *
 * Created on July 4, 2006, 1:11 PM
 *
 */

package galronnlp.util;

import java.util.Iterator;
import java.util.LinkedList;

/**
 *
 * @author Daniel A. Galron
 */
public class UnaryTree extends Tree {
    private boolean displayProbs = true;
    private TreeStringGenerator stringGen = new PennTreebankStringTreeGenerator(displayProbs);
    
    /** Creates a new instance of UnaryTree */
    public UnaryTree(Symbol cat, Tree t, double prob) {
        this.type = UNARY;
        this.category = cat;
        this.probability = prob;
        t.setParent(this);
        this.children.addLast(t);
        
    }
    
    public UnaryTree(Symbol cat, Tree t) {
        this(cat, t, 0.0);
    }
    
    public LinkedList<Symbol> RHS() {
        LinkedList<Symbol> RHS = new LinkedList<Symbol>();
        for(Iterator<Tree> it = this.children.iterator(); it.hasNext(); ) {
            RHS.addLast(it.next().cat());
        }
        return RHS;
    }
    
    public boolean equals(Object o) {
        Tree other = (Tree)o;
        boolean ret = false;
        if(other.type() == UNARY) {
            ret = ((Tree)this.children.get(0)).equals((Tree)other.children.get(0)) &&
                    this.category.equals(other.category);
        }
        return ret;
    }
}
